<?php
namespace Modules\ShopApi\Http\Controllers\v1;
use Illuminate\Http\Request;
use Modules\AuthAdmin\Http\Requests\CommonIdRequest;
use Modules\ShopApi\Models\AuthArea as AuthAreaModel; 
use Modules\ShopApi\Models\ShopSite as ShopSiteModel;
class AddressController extends CommonController
{
	/**
	 * @name  获取省市区
	 * @method  GET	
	 * @return  JSON
	 */
    public function get_area(Request $request)
    {
		return (new AuthAreaModel())->get_area();
    }
	/**
	 * @name  添加地址
	 * @method  POST
	 * @param  province_id int 省id	
	 * @param  city_id int 市id	
	 * @param  county_id int 区县id
	 * @param  name string 收货人
	 * @param  phone string 手机号码
	 * @param  detailed_address string 收货地址
	 * @param  status int 是否默认
	 * @return  JSON
	 */
    public function add_address(Request $request)
    {
		return (new ShopSiteModel())->add_address($request->all());
    }
	/**
	 * @name  我的地址列表
	 * @method  GET
	 * @return  JSON
	 */
    public function get_address_list(Request $request)
    {
		return (new ShopSiteModel())->get_address_list();
    }
	/**
	 * @name  选择默认地址
	 * @method  PUT
	 * @param  id int 地址ID	
	 * @return  JSON
	 */
    public function status(CommonIdRequest $request)
    {
		return (new ShopSiteModel())->status($request->get('id'));
    }
	/**
	 * @name  获取编辑地址数据
	 * @method  GET
	 * @param  id int 地址ID	
	 * @return  JSON
	 */
    public function get_address_info(CommonIdRequest $request)
    {
		return (new ShopSiteModel())->get_address_info($request->get('id'));
    }
	/**
	 * @name  编辑地址
	 * @method  PUT
	 * @param  id int 地址ID	
	 * @param  province_id int 省id	
	 * @param  city_id int 市id	
	 * @param  county_id int 区县id
	 * @param  name string 收货人
	 * @param  phone string 手机号码
	 * @param  detailed_address string 收货地址
	 * @param  status int 是否默认
	 * @return  JSON
	 */
    public function edit_address(Request $request)
    {
		return (new ShopSiteModel())->edit_address($request->all());
    }
	/**
	 * @name  删除收货地址
	 * @method  DELETE
	 * @param  id int 地址ID	
	 * @return  JSON
	 */
    public function delete_address(CommonIdRequest $request)
    {
		return (new ShopSiteModel())->delete_address($request->get('id'));
    }
}
